package com.chz.SupermarketMS.dao;


import com.chz.SupermarketMS.dto.PurchaseHeads;
import com.chz.SupermarketMS.entities.Purchase;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface PurchaseRepository extends CrudRepository<Purchase, Long> {

    static Purchase findByPurchaseId(long theId) {
        return null;
    }

    @Override
    public List<Purchase> findAll();

    @Query(nativeQuery = true,value = "SELECT p.purchase_id as purchaseId, h.name as name, p.data as data  " +
            "FROM chz.purchase p left join chz.head h on p.head_id = h.head_id;"
    )
    List<PurchaseHeads> purchaseHeads();
}
